package it.gestoreContratti.gui.frames;

import it.gestoreContratti.database.DatabaseController;
import it.gestoreContratti.gui.panels.ContrattiScadenzaPanel;
import it.gestoreContratti.gui.panels.NuovoContrattoPanel;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class NuovoContrattoFrame extends JFrame {

	
	private static final long serialVersionUID = -9097563557171838099L;
	private JPanel contentPane;	
	private NuovoContrattoPanel nuovoContrattoPanel;
	private DatabaseController databaseController;
	private ContrattiScadenzaPanel pannello;
	

	/**
	 * Create the frame.
	 */
	public NuovoContrattoFrame(ContrattiScadenzaPanel panel) {
		this.pannello = panel;
		this.databaseController = pannello.getDatabaseController();				
		
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				pannello.refresh();				
			}
		});
		
		setTitle("Inserimento Nuovo Contratto");
		setResizable(false);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setSize(800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0};
		gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		nuovoContrattoPanel = new NuovoContrattoPanel(databaseController);		
		GridBagConstraints gbc_nuovoContrattoPanel = new GridBagConstraints();
		gbc_nuovoContrattoPanel.fill = GridBagConstraints.BOTH;
		gbc_nuovoContrattoPanel.gridx = 0;
		gbc_nuovoContrattoPanel.gridy = 0;
		contentPane.add(nuovoContrattoPanel, gbc_nuovoContrattoPanel);
	}

	
	
	

}
